package fab_api;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.google.api.client.json.JsonFactory;
import com.google.maps.DirectionsApi;
import com.jlkf.common.googleMap.Location;
import com.jlkf.common.googleMap.Routes;
import com.jlkf.common.googleMap.SnapToRoads;
import com.jlkf.common.googleMap.SnappedPoints;
import com.platform.server.util.JSONUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class T {

	public static void main(String[] args) {
//		List<String> readStr = new ArrayList<>();
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		readStr.add(\\\"22.557953334006502,113.94928201599542\\\");
//		
//		
//		String readStr1=\\\"\\\";
//	      if(readStr.size()>2){
//	        	if(readStr.size()>20){
//	        		readStr1+=readStr.get(0);
//	        		int n=readStr.size()/20;
//	        		for(int i=0;i<readStr.size();i++){
//	        			if(i%n==0){
//	        				readStr1+=\\\",\\\"+readStr.get(i);
//	        			}
//	        		}
//	        		readStr1+=\\\",\\\"+readStr.get(readStr.size()-1);
//	        	}
//	        }
//	      System.out.println(\\\"readStr1=======\\\"+readStr1);
		/*String result="{ \"snappedPoints\": [ {  \"location\": {  \"latitude\": 22.557951818474024, \"longitude\": 113.94934653219131 },  \"originalIndex\": 1, \"placeId\": \"ChIJ482GF_ftAzQRoZqGIOFiK6g\" }, { \"location\": {  \"latitude\": 22.5579524185813, }, \"originalIndex\": 2, \"placeId\": \"ChIJ482GF_ftAzQRoZqGIOFiK6g\" },{ \"location\": {  \"latitude\": 22.557953218652855,  \"longitude\": 113.94934653003568   },  \"originalIndex\": 3, \"placeId\": \"ChIJ482GF_ftAzQRoZqGIOFiK6g\" }  ] }";

		JSONObject googleResult=JSONObject.fromObject(result);
		JSONArray snappedPoints=JSONArray.fromObject(googleResult.get("snappedPoints"));
		for(int i=0;snappedPoints.size()>0;i++){
			JSONObject j = JSONObject.fromObject(snappedPoints.get(i));
			JSONObject jj = JSONObject.fromObject(j.get("location"));
			Location l = (Location) JSONObject.toBean(jj, Location.class);
			System.out.println(l.getLatitude());
			System.out.println(l.getLongitude());
		}*/
		
		 Calendar cal = Calendar.getInstance();  
         cal.setTime(new Date());  
         cal.add(Calendar.MONTH, -1);
         System.out.println(cal.getTime());
//		StringBuffer sb = new StringBuffer();
//		sb.append("a");
//		sb.append("d");
//		System.out.println(sb.substring(1));
		/*String status=(String) googleResult.get(\"status\");
		System.out.println(status);
		if(\"OK\".equals(status)){
			JSONArray rowsja = JSONArray.fromObject(googleResult.get(\"routes\"));
			if(rowsja.size()>0){
				Routes rou = (Routes) JSONObject.toBean(JSONObject.fromObject(rowsja.get(0)), Routes.class);
				System.out.println(\"rou=======================\"+rou);
				if(rou!=null){
					System.out.println(rou.getLegs().get(0).getDistance().getValue().doubleValue());;
				}
			}
		}*/
		
		/* JSONArray ja = JSONArray.fromObject(r);
	    System.out.println(ja.size());
	    List<String> li = JSONArray.toList(ja, String.class);
	    List<String> l1=new ArrayList<>();
	    if(li.size()>2){
        	if(li.size()>20){
        		int nn=li.size();
        		int n=nn/20;
        		System.out.println(n);
        		n=n==0?1:n;
        		for(int i=0;i<li.size();i++){
        			if(i%n==0){
        				System.out.println(li.get(i));
        				l1.add(li.get(i));
        			}
        		}
        	}
        }
		System.out.println(l1.size());*/
	}
}
